package com.yit.cn;

/**
 * Created by zhangyanfei on 2019/4/21.
 *
 * @author zhangyanfei
 * @date 2019/04/21
 */
public class PlanA extends AbstractPlan {
    /**
     * normalA
     *
     * 1.25h/km
     *
     * 0.1t /km/t
     */
    Pilot normalApilot = new Pilot("normalA", 1.25, 0.1);

    private SchedulingContext schedulingContext;

    public PlanA(SchedulingContext schedulingContext) {
        super(schedulingContext);
        this.schedulingContext = schedulingContext;

    }

    public Pilot getPilot() {
        schedulingContext.isFly = false;
        schedulingContext.setNormalACanFly(false);
        schedulingContext.setNormalBCanFly(true);
        return normalApilot;
    }

    public boolean condition() {
        if (!schedulingContext.isFly) {
            return false;
        }
        return schedulingContext.isNormalACanFly();
    }

    public String getSFCofDay() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "消耗油量：" + schedulingContext.getLoad() * schedulingContext.getDistance() * normalApilot.getSfc()
                + "吨油量;";
        } else {
            return "消耗油量：" + schedulingContext.getLoad() * schedulingContext.getDistance() * 0.09 + "吨油量;";
        }

    }

    public String getElapsedTime() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "飞行时间：" + schedulingContext.getDistance() / normalApilot.getFlySpeed() + "h;";
        } else {
            return "飞行时间：" + schedulingContext.getDistance() / (1.15 * normalApilot.getFlySpeed()) + "h;";
        }
    }

}
